package com.haiziwang.android;



import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;

public class CommonWebView extends Activity{
	private WebView mWebView;
	private ProgressBar mProgressBar;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.webview);
		
		mProgressBar = (ProgressBar)findViewById(R.id.id_progressBar);
		mWebView = (WebView)findViewById(R.id.webView);
		WebSettings ws = mWebView.getSettings();
		ws.setJavaScriptEnabled(true);
		
		mWebView.setWebViewClient(new WebViewClient() {
			
			@Override
			public void onPageStarted(WebView view, String url, Bitmap favicon) {
				super.onPageStarted(view, url, favicon);
				mProgressBar.setVisibility(View.VISIBLE);
			}

			@Override
			public void onPageFinished(WebView view, String url) {
				super.onPageFinished(view, url);
				mProgressBar.setVisibility(View.GONE);
			}

			@Override
			public boolean shouldOverrideUrlLoading(WebView view, String url) {
				return super.shouldOverrideUrlLoading(view, url);
			}
			
		});
		
		String url = this.getIntent().getExtras().getString("URL");
		mWebView.loadUrl(url);
	}
}
